package com.vitabuybuy.tv.ui.viewmodel

import androidx.lifecycle.MutableLiveData
import com.vitabuybuy.tv.dto.AgreementDto
import com.vitabuybuy.tv.dto.FirstCategoryDto
import com.vitabuybuy.tv.network.AuthRepository
import com.vitabuybuy.tv.network.SettingRepository
import com.vitabuybuy.tv.network.ShopCenterRepository
import com.library.common.base.BaseViewModel
import com.library.common.base.MessageModel
import com.library.common.ext.rxHttpRequest
import com.library.common.net.error.msg
import com.library.common.toast.XToast

class NoViewModel : BaseViewModel() {
    val webContent = MutableLiveData<AgreementDto>()
    fun loadWebViewContet(id: Int?) {
        rxHttpRequest {
            onRequest = {
                webContent.value = AuthRepository.getAgreement(id!!).await()
            }
            onError = {
                XToast.normal(it.msg)
            }
            isShowDialogRequest = true
        }
    }

    fun getServicePhone() {
        rxHttpRequest {
            onRequest = {
                val it =SettingRepository.getServicePhone().await()
                defUI.msgEvent.postValue(MessageModel(1, obj = it))
            }
            onError = {
                XToast.normal(it.msg)
            }
            isShowDialogRequest = true
        }
    }
}